package com.onlyphoto.onlymall.mvp.view.activity

import androidx.recyclerview.widget.LinearLayoutManager
import com.onlyphoto.onlymall.R
import com.onlyphoto.onlymall.base.BaseActivity
import com.onlyphoto.onlymall.bean.response.ArticleBean
import com.onlyphoto.onlymall.mvp.contract.CRaiders
import com.onlyphoto.onlymall.mvp.presenter.PRaidersImpl
import com.onlyphoto.onlymall.mvp.view.binder.RaidersBinder
import kotlinx.android.synthetic.main.activity_raiders.*

import me.drakeet.multitype.Items
import me.drakeet.multitype.MultiTypeAdapter


class RaidersActivity : BaseActivity<PRaidersImpl>(), CRaiders.IVRaiders {

    var layoutManager: LinearLayoutManager? = null
    var items: Items? = null
    var adapter: MultiTypeAdapter? = null

    override fun retry() {}

    override fun init() {
        layoutManager = LinearLayoutManager(this)
        items = Items()
        adapter = MultiTypeAdapter(items!!)
        adapter?.register(ArticleBean::class.java, RaidersBinder())
        rv_raiders.adapter = adapter
        rv_raiders.layoutManager = layoutManager
    }

    override fun initListener() {
        //点击事件初始化
        back.setOnClickListener{
            finish()
        }
    }

    override fun loadData() {
        //加载数据
        mPresenter?.getRaiders(1, 2)
    }

    override fun getRaidersSuccess(list: ArrayList<ArticleBean>) {
        items?.addAll(list)
        adapter?.notifyDataSetChanged()
    }

    override fun isFullScreen(): Boolean {
        //是否沉浸式， 默认非沉浸式
        return false
    }

    public override fun initCustomerStatusManager() {

    }

    override fun setContentViewId(): Int {
        return R.layout.activity_raiders
    }

    override fun createPresenter() {
        mPresenter = PRaidersImpl(mContext, this)
    }

    override fun showLoading() {

    }

    override fun hideLoading() {

    }

}
